package com.zhijian.medical.controller;

import com.zhijian.medical.entity.vo.request.SopRapidPathologicalSaveOrUpdateVo;
import com.zhijian.medical.entity.vo.request.SopRapidPathologicalSaveVo;
import com.zhijian.medical.entity.vo.request.SopRapidPathologicalSearchVo;
import com.zhijian.medical.entity.vo.response.SopRapidPathologicalVo;
import com.zhijian.medical.service.SopRapidPathologicalService;
import com.zhijian.response.annotation.Response;
import com.zhijian.util.page.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * SOP-术中快速病理考核 控制层
 * 
 * @author auto
 * @version 1.0
 * @date 2024-11-14 17:11:00
 */
@Slf4j
@Controller
@Api(tags = "SOP-术中快速病理考核")
public class SopRapidPathologicalController {

	@Autowired
    private SopRapidPathologicalService service;
    
    /**
     * 新增
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sop/rapid/pathological")
    @ApiOperation("新增")
    public boolean insert(@RequestBody SopRapidPathologicalSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return service.save(param);
    }

    @Response
    @PostMapping("/sop/rapid/pathological/new")
    @ApiOperation("新增--新")
    public boolean insertList(@RequestBody SopRapidPathologicalSaveVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return service.saveList(param);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Response
    @DeleteMapping("/sop/rapid/pathological/{id}")
    @ApiOperation("删除")
    public boolean delete(@PathVariable("id") Long id) {
        log.info("{} - {}| delete info", this.getClass().getSimpleName(), id);
        service.deleteById(id);
        return true;
    }

    /**
     * 修改
     *
     * @param id
     * @param param
     * @return
     */
    @Response
    @PutMapping("/sop/rapid/pathological/{id}")
    @ApiOperation("修改")
    public boolean update(@PathVariable("id") Long id, @RequestBody SopRapidPathologicalSaveOrUpdateVo param) {
        log.info("{} - {}| update info, {}", this.getClass().getSimpleName(), id, param);
        param.setId(id);
        return service.modify(param);
    }

    @Response
    @PutMapping("/sop/rapid/pathological/new/{id}")
    @ApiOperation("修改--新")
    public boolean updateNew(@PathVariable("id") Long id, @RequestBody SopRapidPathologicalSaveVo param) {
        log.info("{} - {}| update info, {}", this.getClass().getSimpleName(), id, param);
        param.setId(id);
        return service.modifyNew(param);
    }

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Response
    @GetMapping("/sop/rapid/pathological/{id}")
    @ApiOperation("根据id查询")
    public SopRapidPathologicalVo selectById(@PathVariable("id") Long id) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), id);
        return service.selectVoById(id);
    }

    /**
     * 分页查询
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sop/rapid/pathological/page")
    @ApiOperation("分页查询")
    public Page<SopRapidPathologicalVo> selectByCondition(@RequestBody(required = false) SopRapidPathologicalSearchVo param) {
        if (param == null)
            param = SopRapidPathologicalSearchVo.builder().build();
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
        return service.selectPage(param);
    }

    /**
        * 列表查询
        *
        * @param param
        * @return
    */
    @Response
    @PostMapping("/sop/rapid/pathological/list")
    @ApiOperation("列表查询")
    public List<SopRapidPathologicalVo> selectList(@RequestBody(required = false) SopRapidPathologicalSearchVo param) {
            if (param == null)
            param = SopRapidPathologicalSearchVo.builder().build();
            log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
            return service.selectList(param);
        }

    /**
    * 批量删除
    *
    * @param idList
    * @return
    */
    @Response
    @DeleteMapping("/sop/rapid/pathological/list")
    @ApiOperation("批量删除")
    public boolean delete(@RequestBody(required = false) List<Long> idList) {
        log.info("{} - {}| delete info", this.getClass().getSimpleName(), idList);
        service.deleteByIdList(idList);
        return true;
     }

}